package cn.edu.ecust.seckill.config;

import java.util.ArrayList;
import java.util.List;

public class TaskQueue {

    private List<Task> list;

    public TaskQueue(int size) {
        list = new ArrayList<>(size);
    }

    public synchronized void put(Task task) {
        list.add(task);
    }

    public synchronized List<Task> takeAll() {
        ArrayList<Task> copy = new ArrayList<>(list);
        list.clear();
        return copy;
    }

}
